-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement transformation for TensorFlow 2 Map Function (aka tf.map_fn) #6836
Implement transformation for TensorFlow 2 Map Function (aka tf.map_fn) #6836
Conversation
Signed-off-by: Roman Kazantsev <[email protected]>
Signed-off-by: Roman Kazantsev <[email protected]>
Signed-off-by: Roman Kazantsev <[email protected]>
Signed-off-by: Roman Kazantsev <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are a number of minor comments, but in general looks good. However, I would really want to see a new layer test covering the added functionality:
- A test case where a model has one input which is consumed with the TF
While
operation which produces 2 outputs. - A test case where a model has two inputs which are consumed with the TF
While
operation which produces 2 outputs.
If one of these test cases is already covered with the existing Keras RNN-like tests that is fine. But the case which was not previously supported should be added to the pre-commit layer tests.
Signed-off-by: Roman Kazantsev <[email protected]>
Signed-off-by: Roman Kazantsev <[email protected]>
Thanks for your point. I will add it. |
openvinotoolkit#6836) * Implement transformation for TensorFlow 2 Map Function primitive Signed-off-by: Roman Kazantsev <[email protected]> * Add a description for get_external_node_by_internal_id function Signed-off-by: Roman Kazantsev <[email protected]> * Correct a name for get_external_nodes_by_internal_id function Signed-off-by: Roman Kazantsev <[email protected]> * Fix a description for get_external_nodes_by_internal_id function Signed-off-by: Roman Kazantsev <[email protected]> * Add logging and fix indentation Signed-off-by: Roman Kazantsev <[email protected]> * Use skip_nodes_by_condition to by-pass StopGradient nodes for tf.map_fn Signed-off-by: Roman Kazantsev <[email protected]>
openvinotoolkit#6836) * Implement transformation for TensorFlow 2 Map Function primitive Signed-off-by: Roman Kazantsev <[email protected]> * Add a description for get_external_node_by_internal_id function Signed-off-by: Roman Kazantsev <[email protected]> * Correct a name for get_external_nodes_by_internal_id function Signed-off-by: Roman Kazantsev <[email protected]> * Fix a description for get_external_nodes_by_internal_id function Signed-off-by: Roman Kazantsev <[email protected]> * Add logging and fix indentation Signed-off-by: Roman Kazantsev <[email protected]> * Use skip_nodes_by_condition to by-pass StopGradient nodes for tf.map_fn Signed-off-by: Roman Kazantsev <[email protected]>
openvinotoolkit#6836) * Implement transformation for TensorFlow 2 Map Function primitive Signed-off-by: Roman Kazantsev <[email protected]> * Add a description for get_external_node_by_internal_id function Signed-off-by: Roman Kazantsev <[email protected]> * Correct a name for get_external_nodes_by_internal_id function Signed-off-by: Roman Kazantsev <[email protected]> * Fix a description for get_external_nodes_by_internal_id function Signed-off-by: Roman Kazantsev <[email protected]> * Add logging and fix indentation Signed-off-by: Roman Kazantsev <[email protected]> * Use skip_nodes_by_condition to by-pass StopGradient nodes for tf.map_fn Signed-off-by: Roman Kazantsev <[email protected]>
Root cause analysis: In several TF2 OD models (MobileNet SSD V2, CenterNet) we have a preprocessor block based on tf.map_fn primitive that slices multiple inputs, transform them, and concatenate multiple intermediate outputs at each iteration of While Loop. Currently, the MO tool does not support such block.
Solution: Extend existing transformations for TF2 Keras RNN operations that are particular case of tf.map_fn when it has just one sliced input and one concatenated output. The proposed extension detects sub-graphs (from the main-graph and body-graph) for slicing and concatenation and utilizes
axis
attribute of Loop operation for such operations.Ticket: 47280
Code:
Validation:
Documentation: